#pragma once

// RakNet includes
#pragma comment(lib, "ws2_32.lib")
#include "RakNet\\RakNetworkFactory.h"
#include "RakNet\\RakPeerInterface.h"
#include "RakNet\\MessageIdentifiers.h"
#include "RakNet\\RakSleep.h"
#include "RakNet\\GetTime.h"
#include "RakNet\\BitStream.h"


#include <string>
using namespace std;

/*
*		
*
*/

class Client
{
private:
	int m_port;
	string m_IP;
	bool m_connected;
	RakPeerInterface *m_client;
	SystemAddress m_server;

public:
	Client();
	~Client();

	bool Connect(); // Returns if the connection attempt has failed / succedded.  Could take a few seconds to return.

	void SetPort(int port)			{m_port = port;}
	void SetIP(const string& IP)	{m_IP = IP;}

	Packet* GetIncomingPacket(); // This function does not guarantee a valid packet.
	void KillPacket(Packet *packet);

	// Send a string to the server (needs a message identifier)
	void Send(const char* data);




};




struct TinyMessage // resyncs etc
{
	unsigned char id;
	char str[4];
};

struct SmallMessage // gets / sets / adds / etc
{
	unsigned char id;
	char str[32];

};

struct MediumMessage // who knows
{
    unsigned char id;
    char str[256];
};

struct HugeMessage // chat box lol
{
	unsigned char id;
	char str[2048];
};

struct UtterlyMassiveMessage // why would someone ever need something this massive?
{
	unsigned char id;
	char str[10240];
};

enum MessageTypes
{
	ID_UPDATE_STATS = ID_USER_PACKET_ENUM + 1,
	ID_UPDATE_LOCATION,
	ID_GET,
	ID_RESYNC,
	ID_ADD,

	ID_SAVE,
	ID_LOAD,
	
	ID_LEAVE,

	ID_CHAT,
	ID_SET_NAME,

	ID_CONNECTED_SUCCESS
};

void ParseData(int& pos, string& stored, unsigned char* data);
